home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / mynewfiles.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  4.5 KB  |  211 lines

  1. #include "bbs.h"
  2.  
  3. extern UBYTE NewSinceFlag;
  4.  
  5. static FILE *fp1 = NL;          /* RTS Thu Jan 16 16:24:58 1992 global in mycore2.c */
  6.  
  7. static int TmpDisplayIt(void)
  8. {
  9.  int MoreStat,stat;
  10.  char str[200];
  11.  
  12.  while(fgets(str,180,fp1)!=NULL)
  13.  {
  14.         //str[181]='\0';
  15.         if(str[strlen(str)-1]=='\n') {
  16.          if(gnsflag!=1)            LineCount++;
  17.             strcat(str,"\r");
  18.         }
  19.      AEPutStr(str);
  20.         if(SCheckInput())    {
  21.          stat=ReadChar(1L);
  22.             if(stat<0)
  23.              return(stat);
  24.  
  25.             switch(stat) {
  26.             case '\023': /* Pause */
  27.                 stat=ReadChar(KEYBOARD_TIMEOUT);
  28.                 if(stat<0)
  29.                   return(NO_CARRIER);
  30.                 break;
  31.             case '\003': /* ^C */
  32.                 AEPutStr("**Break\r\n\r\n");
  33.                 return(FAILURE);
  34.             }
  35.         }
  36.      MoreStat=FlagPause(0);
  37.         if(MoreStat<0)
  38.          return(MoreStat);
  39.  
  40.     } 
  41.  return(SUCCESS);
  42. }
  43.  
  44.  
  45. int MyNewFiles(void)
  46. {
  47.  int month,day,year;
  48.  int tv,mystat,stat,Comstat;
  49.  int FLLoop;
  50.  char tempfile[256];         //(RTS) for buffer of upload dir
  51.  char c[256];
  52.  char str[200],ray[200];
  53.  char fn[81],sz[81],dt[81],cmt[81];
  54.  int mdt,ddt,ydt;
  55.  long TimeVar;
  56.  int fcopy = FALSE;
  57.  
  58.  gnsflag=0;
  59.  LineCount = 0;
  60.  
  61.  AEPutStr("\r\n");
  62.  if(MaxDirs==0) {
  63.      MyError(5); // Sorry();
  64.         return(FAILURE);
  65.     }
  66.  
  67.  TimeVar=User.NewSinceDate;
  68.  sprintf(str,"%s",ctime(&TimeVar));
  69.  Convert_CTime_To_Date(str,ray,c);
  70.  
  71.  str[0]='\0';
  72.  
  73.  Comstat=CommandSplit();
  74.  if(Comstat>1) {
  75.      if(Command[1][0]=='s'||Command[1][0]=='S') strcpy(str,ray);
  76.      else        strcpy(str,Command[1]);
  77.     }
  78.  
  79.  while(strlen(str)!=8) {
  80.      Comstat=1;
  81.         sprintf(str,"Date as (mm-dd-yy) to search from (Enter)=%s: ",ray);
  82.      AEPutStr(str);
  83.         mystat=LineInput("",str,8,KEYBOARD_TIMEOUT);
  84.      if(mystat<0)  return(NO_CARRIER);
  85.         if(strlen(str)==0)  strcpy(str,ray);
  86.      if(strlen(str)!=8)  AEPutStr("\r\n");
  87.     }
  88.  sprintf(c,"\tDirectory Scan for (%s)\n",str);
  89.  (void)CallersLog(c);
  90.  
  91.  str[2]=' ';
  92.  str[5]=' ';
  93.  sscanf(str,"%d %d %d",&month,&day,&year);
  94.  
  95.  tv = 0;
  96.  
  97.  if(Comstat>2) {
  98.      strcat(Command[2]," ");
  99.         strcat(Command[2],Command[3]);
  100.      mystat=GetDirSpan(Command[2]);
  101.     } else    mystat=GetDirSpan("\0");
  102.  
  103.  if(mystat==FAILURE)  return(SUCCESS);
  104.  
  105.  gnsflag=CheckForNS(MAINMENU_Li);
  106.  
  107.  NewSinceFlag=1;
  108.  fcopy = FALSE;
  109.  
  110.  FLLoop=StartDir;
  111.  while(FLLoop<=DirScan)    {
  112.      strcpy(str,Conference_Location);
  113.         if(DirScan!=(-1)) {
  114. //(RTS)   buffer upload dir
  115.          if(FLLoop == MaxDirs) {
  116.             strcat(str,"DIR");
  117.                 sprintf(ray,"%d",FLLoop);
  118.                strcat(str,ray);
  119.             sprintf(ray,"Scanning directory %d\r\n",FLLoop);
  120.             AEPutStr(ray);
  121.         
  122.             sprintf(tempfile,"T:tdir.%d",Cmds->AcLvl[LVL_NODE_NUMBER]);
  123.             /* now copy to T: and use T: copy */
  124.            if((FileCopy(str,tempfile))) {
  125.                  strcpy(str,tempfile);
  126.                  fcopy = TRUE;
  127.            }
  128.           
  129.          } else {
  130.             strcat(str,"DIR");
  131.                 sprintf(ray,"%d",FLLoop);
  132.                strcat(str,ray);
  133.             sprintf(ray,"Scanning directory %d\r\n",FLLoop);
  134.                AEPutStr(ray);
  135.          }
  136.         } else {
  137.              strcat(str,"hold/held");
  138.                 AEPutStr("Scanning directory HOLD\r\n");
  139.         }
  140.      stat=FlagPause(1);
  141.         if(stat<0)    {
  142.         if(fcopy) DeleteFile(tempfile);
  143.          return(stat);
  144.      }
  145.      fp1 = fopen(str,"r");
  146.         if(fp1==NULL) {
  147.          AEPutStr("No Files are available.\r\n\r\n");
  148.         if(fcopy) DeleteFile(tempfile);
  149.             return(SUCCESS);
  150.         }
  151.  
  152.  
  153.          while(fgets(c,250,fp1)!=NULL) {
  154.              c[250]='\0'; 
  155.                 if(c[0]==' '||c[0]=='\0'||c[0]=='\n')
  156.                  continue;
  157.              sscanf(c,"%s %s %s %s",&fn,&sz,&dt,&cmt);
  158.                 if(dt[0]<='9'&&dt[0]>='0'&&strlen(dt)==8){
  159.                  if(!(dt[2]=='-'&&dt[5]=='-'&&dt[6]<='9'&&dt[6]>='0')) {
  160.                      strcpy(sz,dt);
  161.                         strcpy(dt,cmt);
  162.                     }
  163.                 } else {
  164.                  strcpy(sz,dt);
  165.                     strcpy(dt,cmt);
  166.                 }
  167.                 dt[2]=' ';
  168.                 dt[5]=' ';
  169.              sscanf(dt,"%d %d %d",&mdt,&ddt,&ydt);
  170.                 if(ydt>year)    tv = 1;
  171.  
  172.              else {
  173.                  if(ydt==year)    {
  174.                      if(mdt>month)     tv = 1;
  175.                      else if(mdt==month)     {
  176.                              if(ddt>=day)    tv = 1;
  177.                         }
  178.                     }
  179.                 }
  180.          if(tv) break;
  181.         } 
  182.  
  183.      if(tv!=0) {
  184.          c[strlen(c)-1]='\0';
  185.             AEPutStr(c);
  186.             AEPutStr("\r\n");
  187.          stat=FlagPause(1);
  188.             if(stat<0)    {
  189.                 fclose(fp1);
  190.              if(fcopy) DeleteFile(tempfile);
  191.                 return(stat);
  192.          }
  193.  
  194. //          stat=DisplayIt();      /* Mikes unbuffered */
  195.           stat=TmpDisplayIt();   /* my buffered dir code */
  196.             fclose(fp1);
  197.           tv=0;
  198.          if(stat<0) {
  199.              if(fcopy) DeleteFile(tempfile);
  200.               return(stat);
  201.          }
  202.         } else        fclose(fp1);
  203.  
  204.      FLLoop+=1;
  205.     }
  206.  AEPutStr("\r\n");
  207.  gnsflag=0;
  208.  if(fcopy) DeleteFile(tempfile);
  209.  return(SUCCESS);
  210. }
  211.